/**
 * 
 * purpose: TEXT AREA... ...
 * @auth: Ning
 * date: 2009-9-19
 * 
 * */
package com.components.text
{
	import fl.managers.FocusManager;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.FocusEvent;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	[Event("change")]
	[TagName("TextArea")]
	
	dynamic public class TextArea extends Sprite
	{
		//START...
		
		//PROPERTY...
		
		private var _label:TextField;
						
		
		//CONSTRUCTOR...
		public function TextArea()
		{
		  
		  	init();	
			
		}
		
		//METHODS...
		
		//initialize...
		private function init():void
		{			
		
			_label = this.getChildByName("txtLabel") as TextField;
			
			_label.addEventListener(Event.CHANGE,labelChgHandler);
			
			addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
			
													
		}
	
					
		//on labe content changed...
		private function labelChgHandler(evt:Event):void
		{
			
			dispatchEvent(evt);
			
		}
		
		//on mouse down...
		private function mouseDownHandler(evt:MouseEvent):void
		{
						
			evt.stopPropagation();
			
		}
		
		//set width...
		
		[Inspectable(type="Number",defaultValue="80")]
		
		public override function set width(value:Number):void
		{
			
			_label.width = value;
			
		}
		
		//get width...
		public override function get width():Number
		{
			
			return _label.width;
			
		}
		
		//set height...
		[Inspectable(type="Number",defaultValue="18")]
		public override function set height(value:Number):void
		{
		
			_label.height = value;		
			
		}		
		
		//get height...
		public override function get height():Number
		{
			
			return _label.height;
			
		}
		
		//auto size...
		
		[Inspectable(enumeration="left,right,none",defaultValue="none")]
		
		public function set autoSize(algin:String):void
		{
			
			_label.autoSize = algin;
			
		}
		
		//get autosize...
		public function get autoSize():String
		{
			
			return _label.autoSize;
			
		}
		
		//multiline...
		[Inspectable(type="Boolean",defaultValue="false")]
		public function set mutiline(value:Boolean):void
		{
			
			_label.multiline = value;
			
		}
		
		
		//get multiline...
		public function get mutiline():Boolean
		{
			
			return _label.multiline;
			
		}
		
		
		//set border...
		[Inspectable(type="Boolean",defaultValue="false")]
		public function set border(val:Boolean):void
		{
			
			_label.border = val;
			
		}
		
		
		//get border...
		public function get border():Boolean
		{
			
			return _label.border;
			
		}
		
		
		//border color...
		[Inspectable(type="Color",defaultValue="#000000")]
		public function set borderColor(color:uint):void
		{
			
			_label.borderColor = color;
			
		}
		
		
		//get border color...
		public function get borderColor():uint
		{
			
			return _label.borderColor;
			
		}
		
		[Inspectable(type="Boolean",defaultValue="false")]
		
		//background...
		public function set background(val:Boolean):void
		{
			
			_label.background = val;
			
		}
		
		
		//get background...
		public function get background():Boolean
		{
			
			return _label.background;
			
		}
		
		[Inspectable(type="Color",defaultValue="#000000")]
		//background color...
		public function set backgroundColor(color:uint):void
		{
			
			_label.backgroundColor = color;
			
		}
		
		
		//get background color...
		public function get backgroundColor():uint
		{
			
			return _label.backgroundColor;
			
		}
		
		[Inspectable(type="Boolean",defaultValue="false")]
		//password...
		public function set displayAsPassword(val:Boolean):void
		{
			
			_label.displayAsPassword = val;	
			
		}
		
		//get password...
		public function get displayAsPassword():Boolean
		{
			
			return _label.displayAsPassword;
		}
		
		[Inspectable(type="String",defaultValue="")]
		//set text...
		public function set text(str:Object):void
		{
			
			_label.text = String(str);
						
			
		}
		
		//get text...
		public function get text():Object
		{
			
			return _label.text;
			
		}
		
		
		[Inspectable(type="String",defaultValue="")]
		//set htmlText...
		public function set htmlText(val:Object):void
		{
			
			_label.htmlText = String(val);	
			
		}
				
		//get htmlText...
		public function get htmlText():Object
		{
			
			return _label.htmlText;
			
		}
		
		
		//get label...
		public function get label():TextField
		{
			
			return _label;
			
		}
		
		[Inspectable(type="Color",defaultValue="#000000")]
		//set text color...
		public function set textColor(val:uint):void
		{
			
			_label.textColor = val;
			
		}
		
		//get text color...
		public function get textColor():uint
		{
			
			return _label.textColor;
			
		}
		
		[Inspectable(enumeration="dynamic,input",defaultValue="dynamic")]
		//set textarea type...
		public function set type(val:String):void
		{
			
			_label.type = val;
			
		}
		
		//get text area type...
		public function get type():String
		{
			
			return _label.type;
			
		}
		
		
		//set selecteabled...
		[Inspectable(type="Boolean",defaultValue="none")]
		public function set selectable(val:Boolean):void
		{
			
			_label.selectable = val;
						
		}
		
		//get selecteabled...
		public function get selectable():Boolean
		{
			
			return _label.selectable;
			
		}
		
		//set font size...
		[Inspectable(type="Number",defaultValue="12")]
		public function set fontSize(val:Number):void
		{
			
			var format:TextFormat = _label.getTextFormat();
		
			format.size = val;
			
			_label.setTextFormat(format);
			
		}
		
		//get font size...
		public function get fontSize():Number
		{
			
			var format:TextFormat = _label.getTextFormat();
		
			return Number(format.size);			
			
		}
		
		//END
	}
}